home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Software / Bonus / Database / mysql-max-3.23.55.sit / mysql-max-3.23.55-apple-darwi.1 / mysql-test / t / alter_table.test < prev    next >
Encoding:
Text File  |  2003-01-21  |  2.4 KB  |  85 lines  |  [TEXT/ttxt]

  1. #
  2. # Test of alter table
  3. #
  4.  
  5. drop table if exists t1;
  6. create table t1 (
  7. col1 int not null auto_increment primary key,
  8. col2 varchar(30) not null,
  9. col3 varchar (20) not null,
  10. col4 varchar(4) not null,
  11. col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
  12. col6 int not null, to_be_deleted int);
  13. alter table t1
  14. add column col4_5 varchar(20) not null after col4,
  15. add column col7 varchar(30) not null after col6,
  16. add column col8 datetime not null, drop column to_be_deleted;
  17. drop table t1;
  18.  
  19. create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
  20. insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
  21. alter table t1 add column new_col int, order by payoutid,bandid;
  22. select * from t1;
  23. alter table t1 order by bandid,payoutid;
  24. select * from t1;
  25. drop table t1;
  26.  
  27. # Check that pack_keys and dynamic length rows are not forced. 
  28.  
  29. CREATE TABLE t1 (
  30. GROUP_ID int(10) unsigned DEFAULT '0' NOT NULL,
  31. LANG_ID smallint(5) unsigned DEFAULT '0' NOT NULL,
  32. NAME varchar(80) DEFAULT '' NOT NULL,
  33. PRIMARY KEY (GROUP_ID,LANG_ID),
  34. KEY NAME (NAME));
  35. #show table status like "t1";
  36. ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
  37. SHOW FULL COLUMNS FROM t1;
  38. DROP TABLE t1;
  39.  
  40. #
  41. # Test of ALTER TABLE ... ORDER BY
  42. #
  43.  
  44. create table t1 (n int);
  45. insert into t1 values(9),(3),(12),(10);
  46. alter table t1 order by n;
  47. select * from t1;
  48. drop table t1;
  49.  
  50. CREATE TABLE t1 (
  51.   id int(11) unsigned NOT NULL default '0',
  52.   category_id tinyint(4) unsigned NOT NULL default '0',
  53.   type_id tinyint(4) unsigned NOT NULL default '0',
  54.   body text NOT NULL,
  55.   user_id int(11) unsigned NOT NULL default '0',
  56.   status enum('new','old') NOT NULL default 'new',
  57.   PRIMARY KEY (id)
  58. ) TYPE=MyISAM;
  59.  
  60. ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
  61. DROP TABLE t1;
  62.  
  63. #
  64. # The following combination found a hang-bug in MyISAM
  65. #
  66.  
  67. CREATE TABLE t1 (AnamneseId int(10) unsigned NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) type=myisam;
  68. insert into t1 values (null,"hello");
  69. LOCK TABLES t1 WRITE;
  70. ALTER TABLE t1 ADD Column new_col int not null;
  71. UNLOCK TABLES;
  72. OPTIMIZE TABLE t1;
  73. DROP TABLE t1;
  74.  
  75. #
  76. # Drop and add an auto_increment column
  77. #
  78.  
  79. create table t1 (i int unsigned not null auto_increment primary key);
  80. insert into t1 values (null),(null),(null),(null);
  81. alter table t1 drop i,add i int unsigned not null auto_increment, drop primary key, add primary key (i);
  82. select * from t1;
  83. drop table t1;
  84.  
  85.